package demo1;

public class Text {
    public static void main(String[] args) {
        Animal animal=new Bird("小鸟",2);
        Bird bird=(Bird)animal;
        bird.fly();//向下转型
        System.out.println("===============");
        Animal animal1=new Dog("旺财",10);
/*        Bird bird1=(Bird)animal1;
        bird1.fly();*/
        if(animal1 instanceof Bird){
            Bird bird1=(Bird)animal1;
            bird.fly();
        }
        else{
            System.out.println("animal instanceof Bird not!!!");
        }

    }
    public static void func(Animal animal){
        animal.eat();
    }
    public static void main2(String[] args) {
        Dog dog=new Dog("旺财",10);
        func(dog);
        System.out.println("=================");
        Bird bird=new Bird("小鸟",2);
        func(bird);
    }
    public static void main1(String[] args) {
        Animal animal=new Dog("旺财",10);
        animal.eat();
    }
}
